package com.edu.service.impl;

import com.edu.dao.EduRoleMapper;
import com.edu.pojo.EduRole;
import com.edu.service.EduRoleService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 管理员用户服务层
 *
 * @author YJF
 */
@Service
public class EduRoleServiceImpl implements EduRoleService {

    @Autowired
    private EduRoleMapper eduRoleMapper;

    @Override
    public List<EduRole> findAll() {
        return eduRoleMapper.selectAll();
    }

    /**
     * 查询条件构建
     *
     * @param eduRole 管理员用户搜索条件
     */
    public Example createExample(EduRole eduRole) {
        Example example = new Example(EduRole.class);
        Example.Criteria criteria = example.createCriteria();
        if (eduRole != null) {
            // 根据管理员名字模糊搜索
            if (!StringUtils.isEmpty(eduRole.getRoleName())) {
                criteria.andLike("roleName", "%" + eduRole.getRoleName() + "%");
            }
        }
        return example;
    }
}
